<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>导入会员</title>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css">
<style type="text/css">
.radio-primary input[type="radio"] + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::before {border-color: #1ab394;}
</style>
</head>
<body>
<body>
<div class="container-fluid">
	<div class="row">
		<h3>1. 支持excel导入，请先下载模板</h3>
		<p>
			<a href="<%=path%>/excel/memberTemplate.xlsx">客户资料模板</a>
		</p>
		<h3>2. 上传导入excel文件</h3>
		<div>
			<input type="file" name="file">
			<p>并严格按照模板格式整理客户资料否则无法导入客户资料</p>
		</div>
		<hr/>
		<p>选择重复数据处理方式（以电话唯一性判断重复数据）</p>
		<div>
		 	<div class="radio radio-primary" style="display:inline-block;">
	        	<input id="a" type="radio" name="type" value="1">
		        <label for="a">重复数据覆盖</label>
		    </div>
		    &nbsp;&nbsp;&nbsp;&nbsp;
		    <div class="radio radio-primary" style="display:inline-block;">
		        <input id="b" type="radio" name="type" value="2" checked="checked">
		        <label for="b">重复数据跳过</label>
		    </div>
	    </div>
	    <br/>
	    <div class="text-center">
	    	<button onclick="parent.importMemberDialog.close().remove()" class="btn btn-sm btn-white" type="button" style="border-color: #18a689;margin-right: 80px;">取消</button>
			<button class="btn btn-sm btn-primary" type="button" id="submit">确定</button>
	    </div>
	</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.fileupload.js"></script>
<script type="text/javascript">
var path = "<%=path%>";
var isGroup = getUrlParam("isGroup");
var name = decodeURIComponent(getUrlParam("name"));
var parentId = getUrlParam("parentId");
var url = path+"/scan/member/importMember";
if(isGroup){
	url = path+"/scan/memberGroup/importMember";
}

$(function(){
	$("#submit").click(function(){
		if($(":file").val() == ""){
			alert("请选择文件");
		}
	});
	
	$(':file').fileupload({
// 		autoUpload: false,
		replaceFileInput: false,
		dataType: "json",
		url : url,
// 		formData: {type: $(":radio[name='type']:checked").val()},
		add: function(e,data){
			$("#submit").click(function(){
				parent.printShadeShow();
				$("#submit").attr("disabled",true);
				data.formData = {
						type: $(":radio[name='type']:checked").val(),
						name:name,
						parentId:parentId
				}
				data.submit();
			});
		},
		done : function(e,data) {
			if(data.result.msg_code == 1){
				alert("导入成功");
				parent.printShadeHide();
				if(isGroup){
					parent.location.href = path+"/view/member/member/groupList?groupId="+data.result.data;
				}
				parent.importMemberDialog.close(data.result.data).remove();
			}
		}
	});
});

function getUrlParam(key){
	var reg = new RegExp("(^|&)"+ key +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}
</script>
</html>